<template>
	<view class="picture" :style="{'width':`${width}rpx`,'height': `${height}rpx`}">
		<image :src="imgurl" :mode="imgInfo() ? 'widthFix' : 'heightFix'" :style="{'width':`${width}rpx`,'height': `${height}rpx`}"></image>
	</view>
</template>

<script>
	export default {
		props: {
			width: {
				type: [Number, String],
				default: '154'
			},
			height: {
				type: [Number, String],
				default: '154'
			},
			imgurl: {
				type: String,
				default: ''
			},
		},
		data () {
			return {
				
			}
		},
		methods:{
			imgInfo() {
				let img = new Image()
				img.src = this.imgurl
				// console.log('width:', img.width,'height:',img.height)
				
				if (img.width >= img.height) {
					return true
				} else {
					return false
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.picture {
		border-radius: 8rpx;
		background: #f5f5f5;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
